import babelpolyfill from 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
import VueRouter from 'vue-router'
import store from './vuex/store'
import Vuex from 'vuex'
import routes from './routes'


import 'font-awesome/css/font-awesome.min.css'
import Moment from 'moment'
import Blob from './excel/Blob.js'
import Export2Excel from './excel/Export2Excel.js'
import {getCookie, delCookie} from "@/api/util"
Vue.prototype.moment = Moment;

Vue.use(ElementUI)
Vue.use(VueRouter)
Vue.use(Vuex)

document.getElementsByTagName('title')[0].innerHTML = '鸿福'
Array.prototype.equals = function (array) {
     // if the other array is a falsy value, return
     if (!array)
         return false;
 
     // compare lengths - can save a lot of time
     if (this.length != array.length)
         return false;
 
     for (var i = 0, l = this.length; i < l; i++) {
         // Check if we have nested arrays
         if (this[i] instanceof Array && array[i] instanceof Array) {
             // recurse into the nested arrays
             if (!this[i].equals(array[i]))
                 return false;
         }
         else if (this[i] != array[i]) {
             // Warning - two different object instances will never be equal: {x:20} != {x:20}
             return false;
         }
     }
     return true;
 }


 
const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
    if(to.path == '/') {
        next({path: '/admin/welcome'})
    }
    if(to.path == '/login') {
	   
    }
    let token = getCookie('token')
    if(!token && to.path != '/login') {
	    next({ path: '/login' })
    } else {
        next()
    }
})



new Vue({
  //el: '#app',
  //template: '<App/>',
  router,
  store,
  //components: { App }
  render: h => h(App)
}).$mount('#app')

